#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int fun(int x, int y)
{
	int t=y;
	while (x % y != 0)
	{
		t = x % y;
		x = y;
		y = t;
	}
	return t;
}
int main()
{
	int n, m;
	int r;
	scanf("%d%d", &n, &m);
	r = fun(n,m);
	printf("%d", r);
	return 0;
}